package org.oc.qaq.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.oc.qaq.annotation.Autofill;
import org.oc.qaq.dto.UserDTO;
import org.oc.qaq.dto.UserPageQueryDTO;
import org.oc.qaq.entity.Role;
import org.oc.qaq.entity.User;
import org.oc.qaq.enumeration.OperationType;

import java.util.List;
import java.util.Set;

@Mapper
public interface UserMapper {

    @Select("select * from user where username=#{username}")
    User selectOneByUsername(String username);

    @Select("select * from user where id=#{id}")
    User selectOneById(String id);

    @Autofill(OperationType.INSERT)
    void insert(User user);

    @Autofill(OperationType.UPDATE)
    void update(User user);

    @Delete("delete from user where id=#{uid}")
    void delete(String uid);

    Set<Role> findRolesByUsername(String username);

    List<UserDTO> list(UserPageQueryDTO queryDTO);
}
